from vanna.ZhipuAI.ZhipuAI_Chat import ZhipuAI_Chat
from vanna.chromadb.chromadb_vector import ChromaDB_VectorStore
from data.user_data import VAN_DB_CONFIG





class ZhipuAIVanna(ChromaDB_VectorStore, ZhipuAI_Chat):
    def __init__(self, config=None):
        ChromaDB_VectorStore.__init__(self, config=config)
        ZhipuAI_Chat.__init__(self, config=config)


class MyVanna:
    def __init__(self, api_key: str):
        vn = ZhipuAIVanna(

            config={"model": "glm-4", "api_key": api_key, "path": "chroma"})  # chatglm2-6b

        vn.connect_to_mysql(**VAN_DB_CONFIG)
        vn.train(ddl="""
        CREATE TABLE IF NOT EXISTS users (
            id INT PRIMARY KEY COMMENT '用户ID'， 
            username VARCHAR(50) COMMENT '用户名'， 
            email VARCHAR(100) COMMENT '电子邮件'， 
            age INT COMMENT '年龄'， 
            gender VARCHAR(10) COMMENT '性别（男/女）'， 
            city VARCHAR(50) COMMENT '城市'
        ) COMMENT='用户信息表' CHARACTER SET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
        """)
        vn.train(ddl="""
CREATE TABLE `order_info`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '订单Id',
  `store_id` bigint unsigned NOT NULL COMMENT '来源平台ID',
  `order_no` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '订单编号',
  `order_parent_no` varchar(125) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '订单父单号',
  `channel` int(0) NOT NULL DEFAULT 0 COMMENT '来源渠道（0：微信小程序，1：租户）',
  `tenant_id` bigint(0) NOT NULL DEFAULT 0 COMMENT '租户id',
  `owner_id` varchar(125) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '货主id',
  `user_id` bigint(0) NOT NULL COMMENT '用户id',
  `user_coupon_id` bigint(0) NOT NULL DEFAULT 0 COMMENT '用户优惠卷id',
  `gift_coupon_id` bigint(0) NOT NULL DEFAULT 0 COMMENT '用户福利券id',
  `remark` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户备注',
  `receiver_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '收件人姓名',
  `receiver_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '收件人手机',
  `receiver_province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '收件地址省',
  `receiver_city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '收件地址市',
  `receiver_district` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '收件地址区',
  `receiver_town` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '收件地址镇/街道',
  `receiver_address` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '收件人详细地址',
  `pick_type` int(0) NOT NULL COMMENT '收货方式（0：配送，1：自提）',
  `self_address_id` bigint(0) NOT NULL DEFAULT 0 COMMENT '自提地址id',
  `coupon_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '优惠金额（包含优惠券和活动等所有优惠）',
  `point_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '积分金额',
  `jdd_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '吉点点金额',
  `card_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '礼品卡积分金额',
  `total_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '订单应付（商品合计 + 运费）',
  `real_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '订单实付（商品合计 + 运费 - 优惠金额 - 积分金额）',
  `invoice_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '开票金额（订单实付）',
  `exp_price` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '运费',
  `push_flag` int(0) NOT NULL DEFAULT 0 COMMENT '是否已推送订单：0-未推送；1-推送成功；2-推送失败',
  `push_failed_reason` varchar(625) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '订单推送失败原因',
  `product_type` int(0) NOT NULL COMMENT '下单商品类型（1-普通商品，2-优惠套餐商品）',
  `order_type` int(0) NOT NULL DEFAULT 0 COMMENT '订单类型（1-普通订单，2-团购订单）',
  `order_status` int(0) NOT NULL COMMENT '订单状态(0-待付款,1-待发货,2-待收货,3-待评价,4-已完成,5-已取消,6-分拣中,7-拼团中)',
  `order_refund_status` int(0) NOT NULL DEFAULT 0 COMMENT '订单退款状态（0-未退款，1-退款成功，2-退款失败）',
  `cancel_status` int(0) NOT NULL DEFAULT -1 COMMENT '订单取消状态（-1：默认未取消，0：不能取消，1：已取消，2：待审核）',
  `reject_cancel_reason` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '拒绝取消原因（严选主动取消原因）',
  `invoice_flag` int(0) NOT NULL COMMENT '是否开发票（0-否，1-开票）',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '下单时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
  `pay_time` datetime(0) DEFAULT NULL COMMENT '支付时间',
  `auto_confirm_time` datetime(0) DEFAULT NULL COMMENT '自动收货时间',
  `confirm_time` datetime(0) DEFAULT NULL COMMENT '确认收货时间',
  `operater` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '操作人',
  `delflag` int(0) NOT NULL DEFAULT 0 COMMENT '删除标示 0：未删除 1：已删除',
  `pay_wechat_notify` int(0) NOT NULL DEFAULT 0 COMMENT '未支付微信公众号通知标志（0：未通知，1：已通知）',
  `settlement_flag` int(0) NOT NULL DEFAULT 0 COMMENT '订单结算标志（0-未结算，1-已结算，2-存疑，3-结算中，4-完成售后，5-售后中）',
  `wrote_off_flag` int(0) NOT NULL DEFAULT 0 COMMENT '冲销标记（0-未冲销，1已冲销）',
  `buyer_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '渠道下单人名称',
  `buyer_phone` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '渠道下单人联系方式',
  `sap_flag` int(0) NOT NULL DEFAULT 0 COMMENT '是否生成出入库单号 0：未生成 1：已生成',
  `relation_order_no` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '关联订单号',
  `extend_field` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '扩展字段JSON格式（（OrderExtendField））',
  `point_type` tinyint(0) DEFAULT -1 COMMENT '积分类型\r\n-1无\r\n0商城积分\r\n1吉点点\r\n2销售公司积分\r\n3领克积分\r\n4魔方积分',
  `money_type` tinyint(0) DEFAULT -1 COMMENT '现金类型\r\n-1无\r\n0微信支付\r\n1支付宝\r\n2安顺微信支付\r\n3安顺支付宝\r\n4安顺云闪付\r\n5新餐卡\r\n6旧餐卡',
  `abnormal_state` bigint(0) DEFAULT 0 COMMENT '异常状态：0无异常，详见：com.hengtiansoft.order.abnormal.model.OrderAbnormalTypeEnum',
  `tenant_settlement_status` tinyint(0) DEFAULT 0 COMMENT '租户结算状态：\r\n0暂不可结算\r\n1待结算\r\n2结算中\r\n3已结算\r\n4无需结算',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uni_orderNo`(`order_no`) USING BTREE,
  INDEX `idx_createTime`(`create_time`) USING BTREE,
  INDEX `idx_payTime`(`pay_time`) USING BTREE,
  INDEX `idx_orderStatus`(`order_status`) USING BTREE,
  INDEX `idx_delflag`(`delflag`) USING BTREE,
  INDEX `idx_userId`(`user_id`) USING BTREE,
  INDEX `idx_productType`(`product_type`) USING BTREE,
  INDEX `index_relationOrderNo`(`relation_order_no`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 743974 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单表【黄健锋】' ROW_FORMAT = Dynamic;
        """)
        vn.train(ddl="""
CREATE TABLE `order_sku`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `product_id` bigint(20) NOT NULL COMMENT '商品id',
  `product_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'spu编码',
  `sku_id` bigint(20) NOT NULL COMMENT 'skuId',
  `sku_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'sku编码',
  `sku_special_code` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'sku特殊code',
  `store_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '平台id',
  `owner_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '货主id',
  `order_no` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '订单号',
  `package_id` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '第三方包裹号（严选）',
  `category_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '末级分类id',
  `category_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '分类名称',
  `brand_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '品牌id',
  `brand_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '品牌名称',
  `product_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '商品名称',
  `sku_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '规格描述',
  `sku_pic_url` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'sku图片',
  `count` int(10) NOT NULL COMMENT '商品数量',
  `origin_price` decimal(10, 2) NOT NULL COMMENT '商品单价（原价）',
  `special_price` decimal(10, 2) NOT NULL COMMENT '商品特价（无特价则与原价相同）',
  `coupon_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '优惠分摊金额',
  `point_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '积分分摊金额',
  `jdd_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '吉点点分摊金额',
  `card_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '礼品卡分摊金额',
  `subtotal_amount` decimal(10, 2) NOT NULL COMMENT '商品小计（单价*数量）',
  `special_amount` decimal(10, 2) NOT NULL COMMENT '活动特价小计（特价*数量）（用于商城展示）',
  `real_subtotal_amount` decimal(10, 2) NOT NULL COMMENT '实付小计（特价*数量 - 优惠分摊金额）',
  `invoice_subtotal_amount` decimal(10, 2) NOT NULL COMMENT '开票金额（实付小计 - 积分分摊金额）',
  `sku_status` int(1) NOT NULL COMMENT 'sku商品状态',
  `stock_out_flag` int(1) NOT NULL DEFAULT 0 COMMENT '发货异常标记（0：正常，1：异常，2：曾标记过异常）',
  `wrote_off_count` int(1) NOT NULL DEFAULT 0 COMMENT '冲销数量（0为未冲销）',
  `remark_order_detail` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '订单详情备注',
  `remark_after_sale` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '售后详情备注',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
  `feedback` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '供应商反馈说明',
  `deliver_error_reason` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货异常原因',
  `overtime_status` tinyint(4) DEFAULT 0 COMMENT '发货超时：0否，1是，2曾经',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_orderNo`(`order_no`) USING BTREE,
  INDEX `idx_skuCode`(`sku_code`) USING BTREE,
  INDEX `idx_skuStatus`(`sku_status`) USING BTREE,
  INDEX `index_productId`(`product_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 50 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单关联sku商品表【黄健锋】' ROW_FORMAT = Dynamic;

                """)

        vn.train(ddl="""        CREATE TABLE IF NOT EXISTS users (
            id INT PRIMARY KEY COMMENT '用户ID'， 
            username VARCHAR(50) COMMENT '用户名'， 
            email VARCHAR(100) COMMENT '电子邮件'， 
            age INT COMMENT '年龄'， 
            gender VARCHAR(10) COMMENT '性别（男/女）'， 
            city VARCHAR(50) COMMENT '城市'
        ) COMMENT='用户信息表' CHARACTER SET=utf8mb4 COLLATE=utf8mb4_unicode_ci;""")
        vn.train(documentation=""" 问题：吉好的商城，spuid=15845的商品，销售总金额为多少？其中吉点点总金额为多少？现金多少？优惠金额为多少？？总共卖了多少坛？
示例：
SELECT
	total_sales_amount,
	jdd_total_amount,
	cash_amount,
	discount_amount,
	total_sold_count ,
		total_sales_amount - jdd_total_amount -cash_amount  otherAmounts
FROM
	(
SELECT
	SUM( os.real_subtotal_amount ) AS total_sales_amount,
	SUM( os.jdd_amount ) AS jdd_total_amount,
	SUM( CASE WHEN oi.money_type = 0 THEN os.real_subtotal_amount ELSE 0 END ) AS cash_amount,
	SUM( os.coupon_amount ) AS discount_amount,
	SUM( os.count ) AS total_sold_count 
FROM
	order_sku os
	JOIN order_info oi ON os.order_no = oi.order_no 
WHERE
	os.product_id = 15845 
	AND oi.tenant_id = 0 
	and oi.order_type != 4
	and oi.product_type !=2
	and oi.create_time>'2023-11-18 15:58:35'
GROUP BY
	os.product_id) as t1""")

        vn.train(documentation=""" item_category表中
item_category 中cate_level分类等级

order_sku中的category_id    为"2级分类Id""")
        vn.train(documentation=""" order_sku 表中
        的real_subtotal_amount  字段 已 扣除优惠金额，在计算时，无需再扣除优惠金额""")
        vn.train(documentation=""" order_info表中
tenant_id字段对应值：0=吉好的  ，4=吉行生活，7=领选生活 ，其余以后会补充先定位其他
order_info表为订单主表
order_sku为order_info 子表""")
        vn.train(documentation=""" 吉好的商城条件下：
order_info表 
total_amount 字段为包含运费总金额与优惠金额 
real_amount字段 根据 money_type字段来区分 金额归属类型
例：money_type=0 时 real_amount即为现金支付""")
        vn.train(documentation=""" 问题：吉好的商城，spuid=15845的商品，销售总金额为多少？其中吉点点总金额为多少？现金多少？其他方式销售金额多少？优惠金额为多少？总共卖了多少坛？
以下为上述问题的答案，百分百准确，其sql中 
SUM(os.real_subtotal_amount - os.jdd_amount - CASE WHEN oi.money_type = 0 THEN os.real_subtotal_amount ELSE 0 END) AS other_amounts为 其他方式销售金额，设字段为other_amounts
答案：
SELECT
    SUM(os.real_subtotal_amount) AS total_sales_amount,
    SUM(os.jdd_amount) AS jdd_total_amount,
    SUM(CASE WHEN oi.money_type = 0 THEN os.real_subtotal_amount ELSE 0 END) AS cash_amount,
    SUM(os.real_subtotal_amount - os.jdd_amount - CASE WHEN oi.money_type = 0 THEN os.real_subtotal_amount ELSE 0 END) AS other_amounts,
    SUM(os.coupon_amount) AS discount_amount,
    SUM(os.count) AS total_sold_count
FROM
    order_sku os
JOIN
    order_info oi ON os.order_no = oi.order_no
WHERE
    os.product_id = 15845
    AND oi.tenant_id = 0
    AND oi.order_type != 4
    AND oi.product_type != 2""")
        vn.train(documentation=""" 以下问题和答案可以用作日后分组查询等借鉴，提到分类： @prev_category := category_id    是需要的
问题：2024-04 的各分类商品 销售额 top10商品 排除掉 已退款订单
问题：按分类分组 获取2024年4月 每个分组销售额前十的商品，排除掉 已退款订单
都应返回以下sql：

SELECT   
    category_id,    
    category_name,    
    product_id,    
    product_name,    
    total_sales_amount,    
    @rank := IF(@prev_category = category_id, @rank + 1, 1) AS rank,    
    @prev_category := category_id    
FROM (  
    SELECT    
        os.category_id,    
        os.category_name,    
        os.product_id,    
        os.product_name,    
        SUM(os.real_subtotal_amount) AS total_sales_amount    
    FROM    
        order_sku os    
    JOIN    
        order_info oi ON os.order_no = oi.order_no    
    LEFT JOIN    
        order_refund_pay orp ON oi.order_no = orp.order_no    
    WHERE    
        orp.order_no IS NULL    
        AND YEAR(oi.create_time) = 2024    
        AND MONTH(oi.create_time) = 3    
    GROUP BY    
        os.category_id, os.category_name, os.product_id, os.product_name    
    ORDER BY    
        os.category_id, SUM(os.real_subtotal_amount) DESC  
) AS sub    
CROSS JOIN (SELECT @rank := 0, @prev_category := NULL) AS vars  
HAVING rank <= 10  
ORDER BY category_id, rank;""")
        vn.train(documentation="""问题：５月份截至昨天　　吉好的主站－供应商这块数码品类的销售明细吗　　
包括商品名称　　产品ID　　和销售数量＋销售金额　
ps:隐藏逻辑：select id  from item_category where name like "%数码%"  and cate_level=1
答案：　
SELECT
    os.product_id AS 产品ID,
    os.product_name AS 商品名称,
    SUM(os.count) AS 销售数量,
    SUM(os.real_subtotal_amount) AS 销售金额
FROM
    order_sku os
JOIN
    order_info oi ON os.order_no = oi.order_no
WHERE
    os.category_id IN (SELECT id FROM item_category WHERE cate_path like '154%')
    AND oi.store_id > 10000
    AND oi.create_time BETWEEN '2023-05-01' AND '2023-05-31'
GROUP BY
    os.product_id, os.product_name;""")
        vn.train(ddl="""CREATE TABLE `item_category`  (
  `id` bigint unsigned NOT NULL COMMENT '类目Id',
  `cate_code` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分类编码',
  `cate_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分类名称',
  `parent_id` bigint unsigned COMMENT '父分类ID',
  `cate_path` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分类id的path，用逗号隔开的分类路径',
  `name_path` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分类名称的path，用逗号隔开的分类路径',
  `cate_level` int(0) DEFAULT NULL COMMENT '分类级别:1.一级分类 2.二级分类',
  `link` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '广告链接',
  `sort` tinyint unsigned COMMENT '排序',
  `pic_url` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '展示的图片的url',
  `description` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '描述',
  `delflag` int(0) NOT NULL DEFAULT 0 COMMENT '删除标示',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `operater` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '操作者',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `cate_path`(`cate_path`) USING BTREE,
  INDEX `parent_id`(`parent_id`) USING BTREE,
  INDEX `cate_name`(`cate_name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 72743 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商品类目【缪诚敏】' ROW_FORMAT = Dynamic;""")
        vn.train(documentation="""数据表中的store_id  对应值
0=自营
1=严选
3=京东
5=EC商城
注：store_id  大于10000 均为 “供应商”""")
        vn.train(ddl="""CREATE TABLE `customer_user`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `phone` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '手机号',
  `user_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户姓名',
  `emp_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户工号',
  `user_pic` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户头像',
  `company_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '公司id',
  `emp_id` bigint(20) DEFAULT NULL COMMENT '员工表id',
  `platform_type` int(10) DEFAULT 0 COMMENT '员工平台类型 0-集团平台员工 3-租户企业员工',
  `tenant_company_id` bigint(20) DEFAULT NULL COMMENT '租户企业id',
  `status` int(1) NOT NULL DEFAULT 1 COMMENT '状态 0-不启用1-启用',
  `user_account` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '账号',
  `oa_account` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '账号',
  `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '密码',
  `pay_password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '密码',
  `open_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'openid',
  `union_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '模板编号',
  `first_login_time` datetime(0) DEFAULT NULL COMMENT '首次登录时间',
  `syn_flag` int(1) DEFAULT 0 COMMENT '同步标示 0-未同步 1-已同步',
  `delflag` int(1) NOT NULL DEFAULT 0 COMMENT '删除标示',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `operater` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '操作者',
  `tenant_user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '租户侧的用户id',
  `nick_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户昵称',
  `is_geely_emp` tinyint(3) UNSIGNED DEFAULT 0 COMMENT '是否是吉利员工：0否，1是',
  `company_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '公司名称',
  `sex` tinyint(4) DEFAULT -1 COMMENT '性别：-1 保密，0女，1男',
  `birthday` datetime(0) DEFAULT NULL COMMENT '生日',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_phone`(`phone`) USING BTREE,
  INDEX `idx_oa_account`(`emp_no`) USING BTREE,
  INDEX `unionId_openId_idx`(`open_id`, `union_id`) USING BTREE,
  INDEX `index_emp_id`(`emp_id`) USING BTREE,
  INDEX `index_tenant_company_id`(`tenant_company_id`) USING BTREE,
  INDEX `customer_user_tenant_user_id_IDX`(`tenant_user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商城用户表 负责人 【陈晓思】' ROW_FORMAT = Dynamic;""")
        vn.train(ddl="""  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '品牌Id',
  `brand_code` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '品牌编码',
  `brand_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '品牌名称',
  `parent_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT '父分类ID',
  `sort` tinyint(4) DEFAULT 100 COMMENT '排序',
  `pic_url` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '展示的图片的url',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '描述',
  `delflag` int(11) NOT NULL DEFAULT 0 COMMENT '删除标示',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `operater` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '操作者',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `brand_name`(`brand_name`) USING BTREE,
  INDEX `sort`(`sort`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1237 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '品牌表【缪诚敏】' ROW_FORMAT = Dynamic;""")
        vn.train(ddl="""CREATE TABLE `platform_user`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `organization_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '组织ID',
  `platform_type` int(11) NOT NULL DEFAULT 0 COMMENT '平台类型 0:平台 1：渠道商 2：供应商 ',
  `account_type` int(11) NOT NULL DEFAULT 2 COMMENT '账户类型：1-预设账户 2-普通账户',
  `username` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '登录账号',
  `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '密码',
  `realname` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '姓名',
  `nickname` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '昵称',
  `phone` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '手机号',
  `status` int(11) NOT NULL DEFAULT 1 COMMENT '1:启用 2:禁用 3:删除',
  `create_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '创建人ID',
  `update_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '修改人ID',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 154 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '平台用户表 【向柯】审核完成' ROW_FORMAT = Dynamic;""")
        vn.train(ddl="""CREATE TABLE `prepay_card`  (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `prepay_card_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '预付卡卡号',
  `prepay_card_secret` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '预付卡卡密',
  `order_no` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '订单号',
  `prepay_classify_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '预付卡类型id',
  `prepay_card_type` int(1) NOT NULL COMMENT '预付卡类型  0-导入预付卡 1-充值预付卡 2-餐卡回退生成',
  `integral` decimal(10, 2) NOT NULL COMMENT '积分数值',
  `residue` decimal(10, 2) NOT NULL COMMENT '积分剩余量',
  `expiry_time` date DEFAULT NULL COMMENT '有效期截至时间',
  `activate_status` int(1) NOT NULL DEFAULT 0 COMMENT '激活状态：0-未激活，1-已激活，2-已过期，3-禁用',
  `activate_time` datetime(0) DEFAULT NULL COMMENT '激活时间',
  `exchange_status` int(1) NOT NULL DEFAULT 0 COMMENT '兑换状态：0-未兑换，1-已兑换',
  `exchange_time` datetime(0) DEFAULT NULL COMMENT '兑换时间',
  `user_id` bigint(20) DEFAULT NULL COMMENT '用户id',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `delflag` int(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0-未删除 1-已删除',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `prepay_card_no`(`prepay_card_no`) USING BTREE,
  UNIQUE INDEX `prepay_card_secret`(`prepay_card_secret`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '预付卡【张幸运】' ROW_FORMAT = Dynamic;""")
        vn.train(ddl="""CREATE TABLE `activation_code_detail`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `code_type` int(1) NOT NULL DEFAULT 0 COMMENT '类型 1-公码 2-私码',
  `user_type` int(1) NOT NULL DEFAULT 0 COMMENT '0-不限 1-新用户',
  `activation_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '激活码名称',
  `store_id` bigint(20) DEFAULT 0 COMMENT '店铺id',
  `code_prefix` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '激活码代码前缀(私码)、公码可忽略该字段',
  `code_count` int(10) NOT NULL DEFAULT 0 COMMENT '激活码数量',
  `active_count` int(10) NOT NULL DEFAULT 0 COMMENT '可使用次数',
  `status` int(3) NOT NULL DEFAULT 1 COMMENT '激活码发布状态 1-未发布 2-已发布 3-已失效',
  `show_flag` int(1) NOT NULL DEFAULT 0 COMMENT '是否在商品详情页展示：0不展示 1展示',
  `effective_status` int(1) NOT NULL DEFAULT 1 COMMENT '激活码生效状态 1未生效 2已生效 3已过期',
  `enable_status` int(1) NOT NULL DEFAULT 1 COMMENT '激活码启用状态 1-未启用 2-已启用',
  `start_time` datetime(0) NOT NULL COMMENT '有效期开始时间',
  `end_time` datetime(0) NOT NULL COMMENT '有效期结束时间',
  `can_edit` int(1) NOT NULL DEFAULT 1 COMMENT '1:可编辑 2:不可编辑',
  `delflag` int(1) NOT NULL DEFAULT 0 COMMENT '删除标示 0：未删除 1：已删除',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `operater` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '操作者',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '激活码基本信息 【戴剑锋】审核完成' ROW_FORMAT = Dynamic;""")
        vn.train(ddl="""CREATE TABLE `activation_code_record`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `activation_code_id` bigint(20) NOT NULL COMMENT '激活码基本信息id',
  `code` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '私激活码代码 前缀+数字',
  `useStatus` int(1) NOT NULL DEFAULT 0 COMMENT '激活码使用状态 0：未使用 1：已使用',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `activation_code_record_IDX1`(`activation_code_id`) USING BTREE,
  INDEX `activation_code_record_IDX2`(`code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '私激活码记录' ROW_FORMAT = Dynamic;
""")
        vn.train(ddl="""CREATE TABLE `activity_bargains_item`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `activity_id` bigint(20) NOT NULL COMMENT '活动id',
  `sku_id` bigint(20) NOT NULL COMMENT 'SkuId',
  `item_id` bigint(20) NOT NULL COMMENT '商品Id',
  `item_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商品名称',
  `normal_price` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '原售价',
  `bargains_price` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '特价',
  `is_limit` int(10) NOT NULL DEFAULT 0 COMMENT '是否限购',
  `limit` int(10) NOT NULL DEFAULT 0 COMMENT '限购数',
  `inventory` int(10) NOT NULL DEFAULT 0 COMMENT '库存 0-不限库存',
  `valid_inventory` int(10) NOT NULL DEFAULT 0 COMMENT '剩余有效库存',
  `checked` int(1) NOT NULL DEFAULT 0 COMMENT '是否选中 0-未选 1-选中',
  `api_limit_flag` smallint(6) NOT NULL DEFAULT 0 COMMENT '是否限流 0否1是',
  `delflag` int(1) NOT NULL DEFAULT 0 COMMENT '删除标示',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `operater` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '操作者',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `IDX1`(`activity_id`, `sku_id`) USING BTREE,
  INDEX `index_activityId`(`activity_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 27 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '特价活动商品表【王智鹏】' ROW_FORMAT = Dynamic;""")
        vn.train(ddl="""CREATE TABLE `activity_base_info`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `activity_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动类型  字典表配置',
  `activity_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动名称 ',
  `description` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '活动描述',
  `range_type` int(1) NOT NULL COMMENT '商品范围类型 0-不限 1-限制品类 2-限制商品',
  `start_time` bigint(20) NOT NULL COMMENT '开始时间',
  `end_time` bigint(20) NOT NULL COMMENT '结束时间',
  `online_time` bigint(20) DEFAULT NULL COMMENT '上线时间',
  `status` int(1) NOT NULL DEFAULT 0 COMMENT '活动状态 0-未上线 1-上线 2-下线',
  `delflag` int(1) NOT NULL DEFAULT 0 COMMENT '删除标示',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `operater` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '操作者',
  `activity_belong` int(1) NOT NULL DEFAULT 0 COMMENT '活动所属（0：平台，1：特定租户，2：全部租户）',
  `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户ID',
  `badge` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '角标',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `activity_base_info_IDX1`(`activity_name`) USING BTREE,
  INDEX `activity_base_info_IDX2`(`activity_type`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 16 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '活动基本信息表【王智鹏】' ROW_FORMAT = Dynamic;""")
        vn.train(ddl="""CREATE TABLE `activity_group_buy`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `store_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `activity_code` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '活动编号',
  `activity_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '活动名称',
  `activity_status` int(1) NOT NULL DEFAULT 0 COMMENT '生效状态 1：已创建 2：上线 3：下线 ',
  `activity_start_time` datetime(0) DEFAULT NULL COMMENT '团购开始时间',
  `activity_end_time` datetime(0) DEFAULT NULL COMMENT '团购结束时间',
  `group_user_num` int(4) NOT NULL DEFAULT 3 COMMENT '成团人数',
  `group_max_num` int(4) NOT NULL DEFAULT 1 COMMENT '一个用户该活动商品最多开团数',
  `group_partake_num` int(4) NOT NULL DEFAULT 0 COMMENT '限制一个用户该活动商品最多参团数',
  `effect_day` int(3) NOT NULL DEFAULT 0 COMMENT '开团有效期',
  `delflag` int(1) NOT NULL DEFAULT 0 COMMENT '删除标示',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `operater` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '操作者',
  `activity_belong` int(1) NOT NULL DEFAULT 0 COMMENT '活动所属（0：平台，1：特定租户，2：全部租户）',
  `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '团购活动表' ROW_FORMAT = Dynamic;""")
        vn.train(ddl="""CREATE TABLE `activity_group_buy_item`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `store_id` bigint(20) NOT NULL DEFAULT 0,
  `activity_code` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '活动编号',
  `sku_id` bigint(20) NOT NULL COMMENT 'SkuId',
  `sku_code` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'SKU编码',
  `item_id` bigint(20) NOT NULL COMMENT '商品Id',
  `item_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商品名称',
  `group_price` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '团购价',
  `is_limit` int(10) DEFAULT 0 COMMENT '是否限购',
  `limit` int(10) DEFAULT 0 COMMENT '限购数',
  `inventory` int(10) NOT NULL DEFAULT 0 COMMENT '活动数量',
  `valid_inventory` int(10) NOT NULL DEFAULT 0 COMMENT '剩余有效数量',
  `delflag` int(1) NOT NULL DEFAULT 0 COMMENT '删除标示',
  `activity_status` int(1) NOT NULL DEFAULT 0 COMMENT '生效状态 1：已创建 2：上线 3：下线 ',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `operater` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '操作者',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '团购商品' ROW_FORMAT = Dynamic;""")
        vn.train(ddl="""CREATE TABLE `activity_order_sku`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `order_id` bigint(20) NOT NULL COMMENT '订单id',
  `sku_id` bigint(20) DEFAULT NULL COMMENT 'SkuId',
  `activity_id` bigint(20) NOT NULL COMMENT '活动id',
  `activity_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动类型',
  `count` int(10) DEFAULT 0 COMMENT '数量',
  `type` int(1) DEFAULT 0 COMMENT '0-商品活动标示 1-订单活动标示',
  `user_id` bigint(20) DEFAULT NULL COMMENT '用户id',
  `delflag` int(1) NOT NULL DEFAULT 0 COMMENT '删除标示',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `operater` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '操作者',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `activity_order_sku_IDX1`(`order_id`) USING BTREE,
  INDEX `activity_order_sku_IDX2`(`sku_id`) USING BTREE,
  INDEX `activity_order_sku_IDX3`(`activity_type`) USING BTREE,
  INDEX `activity_order_sku_IDX5`(`user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单商品活动关联表【王智鹏】' ROW_FORMAT = Dynamic;""")
        vn.train(ddl="""CREATE TABLE `activity_type_info`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `activity_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动类型  字典表配置',
  `activity_type_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动类型名称  字典表配置',
  `price_priority` int(11) NOT NULL DEFAULT 0 COMMENT '结算优先级 （优先级对活动结算顺序排序、结合活动互斥关系表）',
  `show_priority` int(11) NOT NULL DEFAULT 0 COMMENT '显示优先级 （优先级对活动结算顺序排序）',
  `discounts_type` int(1) NOT NULL DEFAULT 0 COMMENT '优惠方式 0-商品单价 1-商品总价 2-订单 3-抽奖',
  `is_calculate` int(1) NOT NULL DEFAULT 0 COMMENT '计算标示 0-结算类型活动 1-其他类型活动',
  `delflag` int(1) NOT NULL DEFAULT 0 COMMENT '删除标示',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `operater` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '操作者',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `activity_type_info_IDX1`(`activity_type`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 18 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '活动类型详情【王智鹏】' ROW_FORMAT = Dynamic;""")
        vn.train(ddl="""CREATE TABLE `activity_type_relation`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `activity_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动类型',
  `mutual_activity_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '互斥活动类型',
  `delflag` int(1) NOT NULL DEFAULT 0 COMMENT '删除标示',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `operater` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '操作者',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `activity_type_relation_IDX1`(`activity_type`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '活动互斥关系表【王智鹏】' ROW_FORMAT = Dynamic;""")
        vn.train(ddl="""CREATE TABLE `address_city`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '市Code',
  `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '市名称',
  `native_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '市nativeCode',
  `upper_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属省code',
  `initial` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '首字母',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 392 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '地址模块-市信息' ROW_FORMAT = Dynamic;
""")

        self.vanna = vn
